package com.example.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Service;

@Service
public class SendMailImpl {
    private String from="2460977458@qq.com";
    private String subject = "注册验证";
    private String context = "您的验证码是：";

    @Autowired
    private JavaMailSenderImpl sender;

    public void sendMail(String to,String code) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setTo(to);
        message.setFrom(from);
        message.setSubject(subject);
        message.setText(context + code + "\n请在5分钟之内输入，5分钟后无效");
        sender.send(message);
    }
}
